
package com.rt.schedulenew.utils.util;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.Connection;
import org.slf4j.Logger;
public class DBUtil
{
    private static final Logger log;
    private static Connection conn;
    private static PreparedStatement ps;
    private static ResultSet rs;
    private static final CallableStatement cs;
    
    public static void query1(final String date, final String queueName) {
        DBUtil.conn = DBConn.conn();
        final String sql = "SELECT DSA.QUEUE_NAME, DSA.SCHEDULE_APM, DSA.QUEUE_APM, DSA.TIME_START, DSA.TIME_END\n\t, DSA.STOP_FLAG, DSA.NOTICE, DSA.APM_LENGTH, DSA.TIME_SIGNIN, DSA.APM_FLAG\n\t, DSA.DRUG_TIME, DSA.TIME_SCHEDULE_LATEST, DSA.TIME_EARLIEST, DSA.DATE_START, DSA.DATE_END\n\t, DSA.APM_CODE, DSA.MAX_LIMIT, DSA.LIMIT_TYPE, DSA.APM_TYPE, DSA.MERGE_APM_CODE\n\t, DSA.WEEK_DATE, DSA.SCHEDULE_DATE\nFROM dict_schedule_apm dsa\nWHERE 1 = 1\n\tAND dsa.apm_type IS NULL\n\tAND dsa.queue_name = ?\n\tAND dsa.schedule_date = ?\nORDER BY dsa.queue_name, dsa.time_start ASC";
        try {
            (DBUtil.ps = DBUtil.conn.prepareStatement(sql)).setString(1, queueName);
            DBUtil.ps.setString(2, date);
            DBUtil.log.info(DBUtil.ps.toString());
            DBUtil.ps.executeUpdate();
            DBUtil.log.info("=======执行jdbc成功==========");
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            DBConn.close();
        }
    }
    
    public static void query2(final String week, final String queueName) {
        DBUtil.conn = DBConn.conn();
        final String sql = "SELECT DSA.QUEUE_NAME, DSA.SCHEDULE_APM, DSA.QUEUE_APM, DSA.TIME_START, DSA.TIME_END\n\t, DSA.STOP_FLAG, DSA.NOTICE, DSA.APM_LENGTH, DSA.TIME_SIGNIN, DSA.APM_FLAG\n\t, DSA.DRUG_TIME, DSA.TIME_SCHEDULE_LATEST, DSA.TIME_EARLIEST, DSA.DATE_START, DSA.DATE_END\n\t, DSA.APM_CODE, DSA.MAX_LIMIT, DSA.LIMIT_TYPE, DSA.APM_TYPE, DSA.MERGE_APM_CODE\n\t, DSA.WEEK_DATE, DSA.SCHEDULE_DATE\nFROM dict_schedule_apm dsa\nWHERE 1 = 1\n\tAND dsa.apm_type IS NULL\n\tAND dsa.queue_name = ?\n\tAND dsa.week_date = ?\nORDER BY dsa.queue_name, dsa.time_start ASC";
        try {
            (DBUtil.ps = DBUtil.conn.prepareStatement(sql)).setString(1, queueName);
            DBUtil.ps.setString(2, week);
            DBUtil.log.info(DBUtil.ps.toString());
            DBUtil.ps.executeUpdate();
            DBUtil.log.info("=======执行jdbc成功==========");
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
        finally {
            DBConn.close();
        }
    }
    
    public static void main(final String[] args) {
        query1("2020-05-18", "手术队列");
    }
    
    static {
        log = LoggerFactory.getLogger((Class)DBUtil.class);
        DBUtil.conn = null;
        DBUtil.ps = null;
        DBUtil.rs = null;
        cs = null;
    }
}
